<? 

require("required/dbconnect.php"); 
require("required/header.php"); 


$latest_order=mysql_query("select * from os_bill_details where DATE_SUB(CURDATE(),INTERVAL 7 DAY)< create_date order by create_date desc,status desc")or die(mysql_error());


?>
<table width="100%"  cellpadding="0" cellspacing="5" height="500">
	<td width="16%" valign="top" height="100%">
		<? require("required/menu.php") ?>
	</td>
	<td class="solidborder" width="84%" valign="top" >
    
		<table width="100%">
			<tr style="background-image: url(images/tbl_th.png);color:#FFFFFF" height="20">
				<td colspan="5"><font color="#FFFFFF">Purchase Reminder</font></td>
			</tr>
			<tr>
				<Td valign="top">
					<table width="90%"><!-- tbl 2-->
					<?	
						if(mysql_num_rows($latest_order)==0)
						{
					?>
						<tr>
							<td align="center"> :: NO RECORD :: </td>
						</tr>
					<?	
						}
						else
						{
					?>
					<tr>
						<td colspan="4">
						Latest order within 7 days 
							<table width="100%" bgcolor="#CCCCCC" cellpadding="1" cellspacing="1"><!-- tbl 1-->
								<tr bgcolor="#F3F3F3" align="center">
									<td width="19%">Order number</td><td width="21%">Order date</td><td width="22%">Member</td><td width="17%">Total amount </td><td width="21%">Status</td>
								</tr>
					<?
							
							while($c=mysql_fetch_array($latest_order))
							{
								$get_member=mysql_query("select * from os_member where id=".$c['uid']);
								
								if(mysql_num_rows($get_member)==0)
								{
									$name="- user not found -";
								}
								else
								{
									$name="<a href='member_viewfull.php?id=".mysql_result($get_member,0,"id")."'>".mysql_result($get_member,0,"name")."</a>";
								}
																												
					?>
								<tr bgcolor="#FFFFFF" align="center">
									
									<td><a href="order_viewfull.php?id=<?= $c['id'] ?>"><?= $c['invoice_number'] ?></a></td><td><?= date("Y-m-d",strtotime($c['create_date'])) ?></td><td><?= $name ?> 	</td>
									<td><font color="#FF0000"><?= number_format($c['total_amount'],2) ?></font></td><td><?= billstatus_eng($c['status']) ?></td>
								</tr>
					<? 					
							} 
					?>
							</table><!-- tbl 1-->
						</td>
					</tr>
				<? } ?>
				</table><!-- tbl 2-->
			</td>
			</tr>
		</table>
		</td>
	</table>
<? require("required/footer.php"); ?>